﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bind.DAL
{
    public class BindDAL
    {
        private ConnectionConfig connection = null;
        public SqlSugarClient db = null;
        public BindDAL()
        {
            string SqlIP = "192.168.2.2";
            string database = "MESDB";
            string uid = "sa";
            string pwd = "8ik,9ol.";
            connection = new ConnectionConfig()
            {
                ConnectionString = "server='" + SqlIP + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            };
            db = new SqlSugarClient(connection);
        }
        public List<BaseModel.MesDb.HkcProgramBind> GetBinds()
        {
            try
            {
                return db.Queryable<BaseModel.MesDb.HkcProgramBind>().ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List<BaseModel.MesDb.HkcProgramData> GetData(string sn)
        {
            try
            {
                return db.Queryable<BaseModel.MesDb.HkcProgramData>().Where(it=>it.sn==sn).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
